/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package an_sim;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

/**
 *
 * @author Karcsi
 */
public class consoleView extends View {

    public consoleView(FullNetwork fn) {
        super(fn);
    }

    public void printSuperNode(int VNid) {

        VirtualNetwork temp = this.fn.getVNByID(VNid);
        System.out.println("║ ┌───────────────┐");
        System.out.println("║ │ID: " + temp.getSuperNode().getID());
        System.out.println("║ │Policy: P:" + temp.getSuperNode().getPolicy().getProvided() + " R:" + temp.getSuperNode().getPolicy().getRequired());
        Iterator<Integer> it = temp.getSuperNode().getNeighbours().iterator();
        System.out.print("║ │Neighbours: ");
        while (it.hasNext()) {
            System.out.print(it.next() + " ");
        }
        System.out.println(";");
        System.out.println("║ └───────────────┘");

    }

    public void printVirtualNetwork(int VNid) {
        VirtualNetwork temp = this.fn.getVNByID(VNid);
        System.out.println("╔════════════════════════════╗");
        printSuperNode(VNid);
        Iterator<Node> it = temp.getMembers().iterator();

        System.out.print("║Member IDs: ");
        while (it.hasNext()) {
            System.out.print(it.next().getID() + " ");
        }
        System.out.println();
        System.out.println("║Level: " + temp.getHierarchyLevel() + " Busy: " + temp.isBusy());
        Iterator<Integer> gwD = temp.getGatewayIdDown().iterator();
        System.out.print("║Gateway ID Down: ");
        while (gwD.hasNext()) {
            System.out.print(gwD.next() + " ");
        }
        System.out.println();
        System.out.println("║Gateway ID Up: " + temp.getGatewayIdUp());
        System.out.println("║Time: " + temp.getTime().getSumTime());
        System.out.println("╚════════════════════════════╝");
    }

    public void printAllSuperNode() {
        Iterator<VirtualNetwork> it = this.fn.getVirtualNetworkList().iterator();
        while (it.hasNext()) {
            printSuperNode(it.next().getSuperNode().getID());
        }


//        int i=0;
//        while(i!=this.fn.getNodeListSize()){
//            printSuperNode(i);
//            i++;
//        }
    }

    public void printAllVirtualNetwork() {
        try {
            Iterator<VirtualNetwork> it = this.fn.getVirtualNetworkList().iterator();
            while (it.hasNext()) {
                printVirtualNetwork(it.next().getSuperNode().getID());
            }
        } catch (Exception e) {
            System.out.println("HIBA::::::::" + e.getMessage());
        }
    }


//        int i=0;
//        while(this.fn.getVNByID(i++)!=null){
//            printVirtualNetwork(i);
//            i++;
//        }
}
